package com.pshcp.tool;

import com.framework.exception.BizException;
import com.framework.tool.CommonTool;
import com.framework.util.SecurityUtil;
import com.pshcp.ao.security.UpdatePasswordAO;
import com.pshcp.domain.model.Doctor;
import com.pshcp.domain.model.PatientUser;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2022/11/4 01:44
 */
public class SecurityTool {

    public static void checkUpdatePassword(UpdatePasswordAO updatePasswordAO) throws BizException {
        CommonTool.checkString(updatePasswordAO.getOldPassword(), "10090001");
        CommonTool.checkString(updatePasswordAO.getNewPassword(), "10090002");
    }

    public static Doctor buildUpdateDoctorPassword(Doctor doctor, UpdatePasswordAO updatePasswordAO) throws Exception {
        doctor.setPassword(SecurityUtil.MD5(updatePasswordAO.getNewPassword()));
        return doctor;
    }

    public static PatientUser buildUpdatePatientPassword(PatientUser patientUser, UpdatePasswordAO updatePasswordAO) throws Exception {
        patientUser.setPassword(SecurityUtil.MD5(updatePasswordAO.getNewPassword()));
        return patientUser;
    }
}
